/**
 * [941] 有效的山脉数组
 *
 * @format
 * @lc app=leetcode.cn id=941 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} arr
 * @return {boolean}
 */
var validMountainArray = function (arr) {
    let [left, right] = [0, arr.length - 1]
    let goL = (goR = true)
    while (goL || goR) {
        arr[left + 1] > arr[left] ? left++ : (goL = false)
        arr[right - 1] > arr[right] ? right-- : (goR = false)
    }
    return left == right && left > 0 && right < arr.length - 1
}
// debugger
// console.log(validMountainArray([0, 3, 2, 1]))
// @lc code=end
